import request from 'umi-request';

export async function getCertificateList(params,status) {
  return request('/hr-ssc/api/api-admin/cer/getCertificateList', {
    method: 'post',
    data: {
      pageNum: params.current,
      pageSize: params.pageSize,
      status:status,
      ...params,
    }
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function getContractModelList() {
  return request('/hr-ssc/api/api-admin/eSign/getContractModelList', {
    method: 'post',
    data:{
      type:6,
      kind:1
    },
    requestType: 'form'
  }).then((res) => {
    return res.data;
  });
}

export async function getContractSubjectList() {
  return request('/hr-ssc/api/api-admin/eSign/getCompanyList', {
    method: 'post',
  }).then((res) => {
    return res.data;
  });
}

export async function saveOrUpdateCertificateInfo(params) {
  return request('/hr-ssc/api/api-admin/cer/saveOrUpdateCertificateInfo', {
    method: 'POST',
    data: {
      ...params,
    },
  }).then((res) => {
    return res;
  });
}

export async function certificateBpm(id) {
  return request('/hr-ssc/api/api-admin/bpm/certificateBpm', {
    method: 'get',
    params:{
      id: id
    }
  }).then((res) => {
    return res;
  });
}

export async function deleteCertificate(id) {
  return request(`/hr-ssc/api/api-admin/cer/deleteCertificate`, {
    method: 'delete',
    params: {id},
  }).then((res) => {
    return res;
  });
}
